package org.come.Jpanel;

import java.awt.Color;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.Graphics;
import java.util.List;

import javax.swing.*;

import org.come.until.ScrollUI;
import org.come.until.SrcollPanelUI;

import com.tool.btn.FormsOnOffBtn;
import com.tool.btn.SupportBtn;
import com.tool.tcpimg.UIUtils;
import com.updateNew.MyIsif;

 

public class SupportListJpanel extends JPanel {

	private JScrollPane jScrollPane; // 召唤兽列表滚动条
	private JList<String> listpet;// 召唤兽列表
	private DefaultListModel<String> listModel;// 放置召唤兽的对象
	private SupportBtn btntop,// 向上图标
			btnbottom,// 向下图标
			btntopset,// 置顶图标
			btnbottomset;// 置底图标
	private JLabel labOpen;
	private JLabel labLocking;
	public JLabel labgundong;
	public SupportListJpanel() {
		String style = MyIsif.getStyle();
		if ("水墨UI".equals(style)) {
				this.setPreferredSize(new Dimension(293, 409));
				this.setLayout(null);
				this.setBackground(UIUtils.Color_BACK);
			// 关闭按钮事件
			FormsOnOffBtn offBtn = new FormsOnOffBtn("inkImg/old/2/1.png", 1, 62);
			offBtn.setBounds(293 - 37, 10, 25, 25);
			this.add(offBtn);
		listModel = new DefaultListModel<String>();
		// 召唤兽列表
		listpet = new JList<String>() {
			{
				setOpaque(false);
			} // instance initializer
		};
		listpet.setSelectionBackground(new Color(33, 42, 52));
		listpet.setFont(new Font("微软雅黑", 1, 14));
		listpet.setBackground(UIUtils.Color_BACK); // 设置列表框为透明背景
		listpet.setForeground(Color.green);
		listpet.setSelectionForeground(Color.green);
		listpet.setModel(listModel);


		// 召唤兽列表滚动条
		jScrollPane = new JScrollPane(listpet);
		jScrollPane.setVerticalScrollBarPolicy(22);
		jScrollPane.getVerticalScrollBar().setUI(new SrcollPanelUI());
		jScrollPane.getViewport().setOpaque(false);
		jScrollPane.setOpaque(false);
		jScrollPane.setBounds(51, 46, 194, 316);
		jScrollPane.setBorder(BorderFactory.createEmptyBorder());
		jScrollPane.setHorizontalScrollBarPolicy(31);
		this.add(jScrollPane);

			// 向上图标
			btntop = new SupportBtn("skin/8100226/button/B42.png", 1, 0, this);
			btntop.setBounds(258, 118, 17, 17);
			this.add(btntop);
			// 向下图标
			btnbottom = new SupportBtn("skin/8100226/button/B43.png", 1, 1, this);
			btnbottom.setBounds(258, 147, 17, 17);
			this.add(btnbottom);
			// 置顶图标
			btntopset = new SupportBtn("skin/8100226/button/19.png", 1, 2,"顶", this);
			btntopset.setBounds(258, 201, 18, 18);
			this.add(btntopset);
			// 置底图标
			btnbottomset = new SupportBtn("skin/8100226/button/19.png", 1, 3,"底", this);
			btnbottomset.setBounds(258, 230, 18, 18);
			this.add(btnbottomset);
		} else {
			this.setPreferredSize(new Dimension(276, 441));
			this.setLayout(null);
			this.setBackground(UIUtils.Color_BACK);
			// 关闭按钮事件
			FormsOnOffBtn offBtn = new FormsOnOffBtn("inkImg/hongmu/s74.png", 1, 62);
			offBtn.setBounds(276, 5, 25, 25);
			this.add(offBtn);

			listModel = new DefaultListModel<String>();

			// 召唤兽列表
			listpet = new JList<String>() {
				{
					setOpaque(false);
				} // instance initializer
			};
			listpet.setSelectionBackground(new Color(31, 7, 8));
			listpet.setFont(new Font("微软雅黑", 1, 14));
			listpet.setBackground(UIUtils.Color_BACK); // 设置列表框为透明背景
			listpet.setForeground(Color.green);
			listpet.setSelectionForeground(Color.green);
			listpet.setModel(listModel);


			// 召唤兽列表滚动条
			jScrollPane = new JScrollPane(listpet);
			jScrollPane.setVerticalScrollBarPolicy(22);
			jScrollPane.getVerticalScrollBar().setUI(new SrcollPanelUI());
			jScrollPane.getViewport().setOpaque(false);
			jScrollPane.setOpaque(false);
			jScrollPane.setBounds(30, 46, 191, 274);
			jScrollPane.setBorder(BorderFactory.createEmptyBorder());
			jScrollPane.setHorizontalScrollBarPolicy(31);
			this.add(jScrollPane);

			// 向上图标
			this.btntop = new SupportBtn("img/xy2uiimg/42_png.button.btn_1.png", 1, 0, this);
			this.btntop.setBounds(238, 118, 20, 20);
			this.add(btntop);
			// 向下图标
			this.btnbottom = new SupportBtn("img/xy2uiimg/34_png.button.xy_vscroll$down.png", 1, 1, this);
			this.btnbottom.setBounds(238, 147, 20, 20);
			this.add(btnbottom);
			// 置顶图标
			this.btntopset = new SupportBtn("img/xy2uiimg/topset.png", 1, 2, this);
			this.btntopset.setBounds(238, 201, 17, 17);
			this.add(btntopset);
			// 置底图标
			this.btnbottomset = new SupportBtn("img/xy2uiimg/bottomset.png", 1, 3, this);
			this.btnbottomset.setBounds(238, 230, 17, 17);
			this.add(btnbottomset);
		}
	}

	private ImageIcon icon;

	@Override
	protected void paintComponent(Graphics g) {
		super.paintComponent(g);
//		if (icon == null)
		String style = MyIsif.getStyle();
		if ("水墨UI".equals(style)) {
				icon = new ImageIcon("inkImg/newbackground/B254.png");
				// 背景
				g.drawImage(icon.getImage(), 0, 0, 293, 409, this);
		} else {
			icon = new ImageIcon("inkImg/newhongmu/B254.png");
			// 背景
			g.drawImage(icon.getImage(), 0, 0, this);
		}
	}

	// 初始列表
	public void init(List<String> list) {
		listModel.clear();
		for (int i = 0; i < list.size(); i++) {
			listModel.addElement(list.get(i));
		}
	}

	public DefaultListModel<String> getListModel() {
		return listModel;
	}

	public void setListModel(DefaultListModel<String> listModel) {
		this.listModel = listModel;
	}

	public JList<String> getListpet() {
		return listpet;
	}

	public void setListpet(JList<String> listpet) {
		this.listpet = listpet;
	}

}
